package com.hl.qzzpbackend.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hl.qzzpbackend.common.BaseResponse;
import com.hl.qzzpbackend.common.DeleteRequest;
import com.hl.qzzpbackend.common.ResultUtils;
import com.hl.qzzpbackend.model.dto.industryType.IndustryTypeAddRequest;
import com.hl.qzzpbackend.model.dto.industryType.IndustryTypeQueryRequest;
import com.hl.qzzpbackend.model.dto.industryType.IndustryTypeUpdateRequest;
import com.hl.qzzpbackend.model.vo.IndustryTypeAndPositionTypeVO;
import com.hl.qzzpbackend.model.vo.IndustryTypeVO;
import com.hl.qzzpbackend.model.vo.PositionTypeVO;
import com.hl.qzzpbackend.service.IndustryTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 行业类型 接口
 *
 * @author helong
 */
@Slf4j
@Api(tags = "行业类型接口")
@RestController
@RequestMapping("/industry_type")
public class IndustryTypeController {

    @Resource
    private IndustryTypeService industryTypeService;

    // 添加行业类型
    @ApiOperation(value = "添加行业类型")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public BaseResponse<Boolean> industryTypeAdd(@Valid @RequestBody IndustryTypeAddRequest industryTypeAddRequest) {
        if(log.isInfoEnabled()){
            log.info("添加行业类型 {}", industryTypeAddRequest);
        }
        boolean result = industryTypeService.industryTypeAdd(industryTypeAddRequest);
        return ResultUtils.success(result);
    }

    // 修改行业类型
    @ApiOperation(value = "修改行业类型")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public BaseResponse<Boolean> industryTypeUpdate(@Valid @RequestBody IndustryTypeUpdateRequest industryTypeUpdateRequest) {
        if(log.isInfoEnabled()){
            log.info("修改行业类型 {}", industryTypeUpdateRequest);
        }
        boolean result = industryTypeService.industryTypeUpdate(industryTypeUpdateRequest);
        return ResultUtils.success(result);
    }

    // 删除行业类型
    @ApiOperation(value = "删除行业类型")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public BaseResponse<Boolean> industryTypeDelete(@Valid @RequestBody DeleteRequest deleteRequest) {
        if(log.isInfoEnabled()){
            log.info("删除行业类型 {}", deleteRequest);
        }
        boolean result = industryTypeService.industryTypeDelete(deleteRequest);
        return ResultUtils.success(result);
    }

    // 行业类型分页查询
    @ApiOperation(value = "行业类型分页查询")
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public BaseResponse<Page<IndustryTypeVO>> getIndustryTypePage(@RequestBody IndustryTypeQueryRequest industryTypeQueryRequest) {
        if(log.isInfoEnabled()){
            log.info("行业类型分页查询 {}", industryTypeQueryRequest);
        }
        Page<IndustryTypeVO> pageVO= industryTypeService.getIndustryTypePage(industryTypeQueryRequest);
        return ResultUtils.success(pageVO);
    }

    // 获取所有行业类型且包含岗位类型
    @ApiOperation(value = "获取所有行业类型且包含岗位类型")
    @RequestMapping(value = "/listWithPositionType", method = RequestMethod.GET)
    public BaseResponse<List<IndustryTypeAndPositionTypeVO>> getListWithPositionType() {
        if(log.isInfoEnabled()){
            log.info("获取所有行业类型且包含岗位类型");
        }
        List<IndustryTypeAndPositionTypeVO> list= industryTypeService.getListWithPositionType();
        return ResultUtils.success(list);
    }

    // 获取所有行业类型
    @ApiOperation(value = "获取所有行业类型")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public BaseResponse<List<IndustryTypeVO>> getIndustryTypeVOList() {
        if(log.isInfoEnabled()){
            log.info("获取所有行业类型");
        }
        List<IndustryTypeVO> list= industryTypeService.getIndustryTypeVOList();
        return ResultUtils.success(list);
    }


}
